package com.hm.myapplication;

import android.content.Context;
 import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MyPagerAdapter extends PagerAdapter {

    private Context mContext;


    public MyPagerAdapter(Context context) {
        mContext = context;
    }

    @Override
    public int getCount() {
        return 5;
    }

    @NonNull
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = View.inflate(mContext, R.layout.item_list, null);
        List<String> myDataList = List.of(position+"...1",position+"...2",position+"...3",position+"...4",position+"...5",position+"...6",position+"...7"
                ,position+"...8",position+"...9",position+"...10",position+"...11",position+"...12",position+"...13");
      //  ListView list = view.findViewById(R.id.list);
        RecyclerView recyclerView = view.findViewById(R.id.list);

        recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
        MyAdapter adapter = new MyAdapter(myDataList);
        recyclerView.setAdapter(adapter);

       // list.setAdapter(new SimpleAdapter(container.getContext(), mData, R.layout.item_base, new String[]{"key"}, new int[]{R.id.iv}));
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}
